package com.ruoyi.project.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouse.domain.RyDepot;
import com.ruoyi.project.warehouse.service.IRyDepotService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 仓库管理Controller
 *
 * @author you
 * @date 2022-09-05
 */
@RestController
@RequestMapping("/warehouse/RyDepot")
public class RyDepotController extends BaseController
{
    @Autowired
    private IRyDepotService ryDepotService;

    /**
     * 查询所有仓库列表
     */
    @GetMapping("/all")
    public AjaxResult all()
    {
//        startPage();
        List<RyDepot> list = ryDepotService.all();
        return AjaxResult.success(list);
    }

    /**
     * 查询仓库管理列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyDepot ryDepot)
    {
        startPage();
        List<RyDepot> list = ryDepotService.selectRyDepotList(ryDepot);
        return getDataTable(list);
    }

    /**
     * 导出仓库管理列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:export')")
    @Log(title = "仓库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyDepot ryDepot)
    {
        List<RyDepot> list = ryDepotService.selectRyDepotList(ryDepot);
        ExcelUtil<RyDepot> util = new ExcelUtil<RyDepot>(RyDepot.class);
        util.exportExcel(response, list, "仓库管理数据");
    }

    /**
     * 获取仓库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ryDepotService.selectRyDepotById(id));
    }

    /**
     * 新增仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:add')")
    @Log(title = "仓库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyDepot ryDepot)
    {
        return toAjax(ryDepotService.insertRyDepot(ryDepot));
    }

    /**
     * 修改仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:edit')")
    @Log(title = "仓库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyDepot ryDepot)
    {
        return toAjax(ryDepotService.updateRyDepot(ryDepot));
    }

    /**
     * 删除仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyDepot:remove')")
    @Log(title = "仓库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryDepotService.deleteRyDepotByIds(ids));
    }
}
